package org.example.dao;

/**
 * @BelongsProject: Dynamic-relationship-binding
 * @BelongsPackage: org.example.dao
 * @Author: dengxiyan
 * @CreateTime: 2025/07/04  10:55
 * @Description: 仓库接口
 * @Version: 1.0
 */

import org.example.model.RelationMetadata;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;

import java.util.List;

public interface RelationMetadataRepository extends JpaRepository<RelationMetadata, Long> {
    List<RelationMetadata> findBySourceEntityAndSourceId(String sourceEntity, Long sourceId);

    Page<RelationMetadata> findBySourceEntityAndSourceId(String sourceEntity, Long sourceId, Pageable pageable);

    Page<RelationMetadata> findByTargetEntityAndTargetId(String targetEntity, Long targetId, Pageable pageable);

    List<RelationMetadata> findByTargetEntityAndTargetId(String targetEntity, Long targetId);

    @Modifying
    void deleteBySourceEntityAndSourceIdAndTargetEntityAndTargetId(String sourceEntity, Long sourceId, String targetEntity, Long targetId);
}
